/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gestiontienda.web.venta;

import java.util.Set;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import gestiontienda.GenerateFactory;
import gestiontienda.dataaccess.daofactory.DaoFactory;
import gestiontienda.dataaccess.domain.VentaDAO;
import gestiontienda.dataaccess.model.VentaVO;
import java.util.Iterator;
import java.util.List;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
/**
 *
 * @author igorov
 */
@ParentPackage(value = "gestiontienda")
public class GestionVenta extends ActionSupport {
    
    private HttpSession session;
    private List<VentaVO> ventaVOs;
    
    @Action(value = "/verVentas", results = {
        @Result(location = "venta/verVentas.jsp", name = "success"),
        @Result(location = "usuario/bienvenido.jsp", name = "error")
    })
    public String configurar_evento() {
        System.out.println("ver Ventas");
        return SUCCESS;
    }
    
    @Action(value = "/tablaVentas", results = {
        @Result(type = "json", name = "success")
    })
    public String tablaAuditorios() {

        DaoFactory daoFactory = GenerateFactory.getInstance(0);
        VentaDAO ventaDAO = daoFactory.createVentaDAO();
        
        
        System.out.println("***jsonVentas");
        session = ServletActionContext.getRequest().getSession();

        
        List<VentaVO> ventaVOs = ventaDAO.getAll();
        for (Iterator<VentaVO> it = ventaVOs.iterator(); it.hasNext();) {
            VentaVO ventaVO = it.next();
            ventaVOs.add(ventaVO);
            
        }
        
        setVentaVOs(ventaVOs);

        return SUCCESS;
    }

    public List<VentaVO> getVentaVOs() {
        return ventaVOs;
    }

    public void setVentaVOs(List<VentaVO> ventaVOs) {
        this.ventaVOs = ventaVOs;
    }
    
    
}
